#define _CRT_SECURE_NO_WARNINGS 1
#include"game.h"
void Menu()
{
	printf("---------Menu--------\n");
	printf("---------------------\n");
	printf("-       1.Play      -\n");
	printf("---------------------\n");
	printf("-       0.Exit      -\n");
	printf("---------------------\n");
}
void InitBoard(char Board[ROWS][COLS],char k)
{
	int i = 0;
	for (i = 0; i < ROWS; i++)
	{
		int j = 0;
		for (j = 0; j < COLS; j++)
		{
			Board[i][j] = k;
		}
	}
}
void PrintBoard(char Board[ROWS][COLS])
{
	//printf("%c ",'\\');
	for (int i = 0; i <= ROW ; i++)
	{
		printf("%d ", i);
	}
	printf("\n");
	int i = 0;
	for (i = 1; i <= ROW; i++)
	{
		printf("%d ", i );
		int j = 0;
		for (j = 1; j <= COL; j++)
		{
			printf("%c ", Board[i][j]);
		}
		printf("\n");
	}
}
void SetMine(char Mine[ROWS][COLS])
{
	int i = 0;
	int x = 0;
	int y = 0;
	//布置雷的个数
	while(i<MineCount)
	{
		x = rand() % ROW+1;
		y = rand() % COL+1;
		if (Mine[x][y] != '1')
		{
			Mine[x][y] = '1';
			i++;
		}
	}
	
}
void SweepMine(char Mine[ROWS][COLS], char Show[ROWS][COLS])
{
	int i = 0;
	while (i < ROW * ROW - MineCount)
	{
		i++;
		printf("请输入想要排查的坐标：");
		int r = 0;
		int c = 0;
		scanf("%d %d", &r, &c);
		if (Mine[r][c] == '1')
		{
			printf("很遗憾，你踩雷了\n");
			printf("以下是所有雷的位置,1代表雷，0代表无雷\n");
			PrintBoard(Mine);
			break;
		}
		else
		{
			//周围雷的个数统计并打印
			int AroundMineCount = Mine[r - 1][c - 1] +
				Mine[r][c - 1] +
				Mine[r + 1][c - 1] +
				Mine[r][c - 1] +
				Mine[r][c] +
				Mine[r][c + 1] +
				Mine[r + 1][c - 1] +
				Mine[r + 1][c] +
				Mine[r + 1][c + 1] - '0' * 9;
			Show[r][c] = AroundMineCount + '0';
			printf("--------------------------\n");
			PrintBoard(Show);
		}
	}
	if (i == ROW * ROW - MineCount)
	{
		printf("恭喜你，成功排查出所有的雷\n");
	}
}


